翻訳と辞書
Words near each other
・ Pure (Baggott novel)
・ Pure (Boney James album)
・ Pure (Canadian band)
・ Pure (Chris Potter album)
・ Pure (company)
・ Pure (Dream song)
・ Pure (Gary Numan album)
・ Pure (Godflesh album)
・ Pure (Hayley Westenra album)
・ Pure (Lara Fabian album)
・ Pure (Maksim Mrvica album)
・ Pure (Miller novel)
・ Pure (No Angels album)
・ Pure (Orgy song)
・ Pure (Pendragon album)
Pure (programming language)
・ Pure (The Golden Palominos album)
・ Pure (The Jesus Lizard album)
・ Pure (The Lightning Seeds album)
・ Pure (The Lightning Seeds song)
・ Pure (The Primitives album)
・ Pure (The Times album)
・ Pure (video game)
・ Pure 107.8FM
・ Pure Acid Park
・ Pure Air
・ Pure alexia
・ Pure and Applied Chemistry
・ Pure and Simple
・ Pure and Simple (album)


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Pure (programming language) : ウィキペディア英語版
Pure (programming language)

Pure is a dynamically typed, functional programming language based on term rewriting. It has facilities for user-defined operator syntax, macros, multiple-precision numbers, and compilation to native code through the LLVM. It is the successor to the Q programming language.
Pure comes with an interpreter and debugger, provides automatic memory management, and has powerful functional and symbolic programming capabilities as well as interface to C libraries (e.g. for numerics, low-level protocols, and other such tasks). At the same time, Pure is a "small" language designed from scratch; its interpreter is not large, and the library modules are written in Pure itself. The syntax of Pure resembles that of Miranda and Haskell, but it is a free-format language and thus uses explicit delimiters (rather than indentation) to indicate program structure.
The Pure language is a successor of the Q language created previously by the same author, Albert Gräf at the University of Mainz in Germany. Compared to Q, it offers some important new features (in particular, local functions with lexical scoping, efficient vector and matrix support and the built-in C interface) and programs run much faster as they are JIT-compiled to native code on the fly. Pure is mostly aimed at mathematical applications and scientific computing currently, but its interactive interpreter environment, the C interface and the growing collection of addon modules make it suitable for a variety of other applications, such as artificial intelligence, symbolic computation, and real-time multimedia processing.
Pure plugins are available for the Gnumeric spreadsheet and Miller Puckette's Pure Data graphical multimedia software, which make it possible to extend these programs with functions written in the Pure language. Interfaces to GNU Octave, OpenCV, OpenGL, the GNU Scientific Library, FAUST, SuperCollider and liblo (for OSC) are also provided as library modules.
Pure is free software distributed (mostly) under the GNU Lesser General Public License version 3 (or later).
==Examples==

The Fibonacci numbers (naive version):

fib 0 = 0;
fib 1 = 1;
fib n = fib (n-2) + fib (n-1) if n>1;

Better (tail-recursive and linear-time) version:

fib n = fibs (0,1) n with
fibs (a,b) n = if n<=0 then a else fibs (b,a+b) (n-1);
end;

Compute the first 20 Fibonacci numbers:

map fib (1..20);

An algorithm for the n queens problem which employs a list comprehension to organize the backtracking search:

queens n = search n 1 ;
safe (i,j) p = ~any (check (i,j)) p;
check (i1,j1) (i2,j2)
= i1==i2 || j1==j2 || i1+j1==i2+j2 || i1-j1==i2-j2;
end;

While Pure uses eager evaluation by default, it also supports lazy data structures such as streams (lazy lists). For instance, here is a (suboptimal) trial division version of the sieve of Eratosthenes (attributed to David Turner〔Turner, David A. SASL language manual. Tech. rept. CS/75/1. Department of Computational Science, University of St. Andrews 1975.〕) which computes the stream of all prime numbers:

primes = sieve (2..inf) with
sieve (p:qs) = p : sieve (| q = qs; q mod p ) &;
end;

Note the use of the & operator which turns the tail of the sieve into a thunk to delay its computation. The thunk is evaluated implicitly and then memoized (using call by need evaluation) when the corresponding part of the list is accessed, e.g.:
primes!!(0..99); // yields the first 100 primes
Pure has efficient support for vectors and matrices (similar to that provided by MATLAB and GNU Octave), including vector and matrix comprehensions. E.g., a Gaussian elimination algorithm with partial pivoting can be implemented as follows in Pure:

gauss_elimination x::matrix = p,x
when n,m = dim x; p,_,x = foldl step (0..n-1,0,x) (0..m-1) end;

step (p,i,x) j
= if max_x==0 then p,i,x else
// updated row permutation and index:
transp i max_i p, i+1,
;
x; gauss_elimination x;

As a language based on term rewriting, Pure fully supports symbolic computation with expressions. Here is an example showing the use of local rewriting rules to expand and factor simple arithmetic expressions:

expand = reduce with
(a+b)
*c = a
*c+b
*c;
a
*(b+c) = a
*b+a
*c;
end;

factor = reduce with
a
*c+b
*c = (a+b)
*c;
a
*b+a
*c = a
*(b+c);
end;

expand ((a+b)
*2); // yields a
*2+b
*2
factor (a
*2+b
*2); // yields (a+b)
*2

Calling C functions from Pure is very easy. E.g., the following imports the puts function from the C library and uses it to print the string "Hello, world!" on the terminal:

extern int puts(char
*);
hello = puts "Hello, world!";
hello;


抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Pure (programming language)」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.